package com.atguigu.practice;

import java.util.Scanner;
import java.util.Stack;

public class LegalBracketsJudgement {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str=scanner.next();
        int n=scanner.nextInt();
        //括号数为奇数数时无法匹配
        if((n&1)==1){
            System.out.println(false);
            return;
        }
        //存在非括号时，无法匹配
        for(int i=0;i<str.length();i++){
            char ch=str.charAt(i);
            if(ch!='('&&ch!=')'){
                System.out.println(false);
                return;
            }
        }
        Stack<Character> stack=new Stack<>();
        for(int i=0;i<str.length();i++){
            char ch=str.charAt(i);
            if(ch=='('){
                stack.push(ch);
                continue;
            }else if(ch==')'){
                stack.pop();
                continue;
            }
        }
        if(stack.isEmpty()){
            System.out.println(true);
            return;
        }
        System.out.println(false);
    }
}
